efform_onload = function ()
{
};  

button_query_onclick = function () 
{   	
	efgrid.submitInqu("ef_grid_result", "ZM", "ZMCG82", "query");
}

button_update_onclick = function (){ 
	var grid=isSelected("ef_grid_result");
	if (grid == 0)return; 
	var rows=grid.getCheckedRows();
	for(var i=0;i<rows.length;i++)
	{
		var fdWorkbeforeTime = grid.getCellValueByColumnName(rows[i],"fdWorkbeforeTime"); //班前确认时间
		var fdWorkmoddleTime = grid.getCellValueByColumnName(rows[i],"fdWorkmoddleTime"); //班中确认时间
		var fdWorklastTime = grid.getCellValueByColumnName(rows[i],"fdWorklastTime");  //班末确认时间
		if(fdWorkmoddleTime <= fdWorkbeforeTime)
		{
			EFAlert("班中时间早于班前时间"); return;
		}
		if(fdWorklastTime <= fdWorkmoddleTime)
		{
			EFAlert("班末时间早于班中时间"); return;
		}
		if(grid.getCellValueByColumnName(rows[i], "fdStatus") != "草拟")
		{
			EFAlert("只能修改状态为草拟的数据！"); return;
		}
	}
	if (isSelected("ef_grid_result") == 0)return; 
	efgrid.submitForm("ef_grid_result", "ZM", "ZMCG82", "update", true);
}

button_insert_onclick = function (){
	var grid=isSelected("ef_grid_result");
	if (grid == 0)return; 
	var rows=grid.getCheckedRows();
	for(var i=0;i<rows.length;i++)
	{
		var fdWorkbeforeTime = grid.getCellValueByColumnName(rows[i],"fdWorkbeforeTime"); //班前确认时间
		var fdWorkmoddleTime = grid.getCellValueByColumnName(rows[i],"fdWorkmoddleTime"); //班中确认时间
		var fdWorklastTime = grid.getCellValueByColumnName(rows[i],"fdWorklastTime");  //班末确认时间
		if(fdWorkmoddleTime <= fdWorkbeforeTime)
		{
			EFAlert("班中时间早于班前时间"); return;
		}
		if(fdWorklastTime <= fdWorkmoddleTime)
		{
			EFAlert("班末时间早于班中时间"); return;
		}
	}
	if (isSelected("ef_grid_result") == 0)return; 
	efgrid.submitForm("ef_grid_result", "ZM", "ZMCG82", "insert", true);
}

button_delete_onclick = function (){
	var grid=isSelected("ef_grid_result");
	if (grid == 0)return; 
	var rows=grid.getCheckedRows();
	for(var i=0;i<rows.length;i++)
	{
		if(grid.getCellValueByColumnName(rows[i], "fdStatus") != "草拟")
		{
			EFAlert("只能删除状态为草拟的数据！"); return;
		}
	}
	EFConfirm('你确认要删除吗?', '确认框', function(r) {
		if(r)efgrid.submitForm("ef_grid_result", "ZM", "ZMCG82", "delete", true);
	}); 
}

button_report_onclick = function (){
	var grid=isSelected("ef_grid_result");
	if (grid == 0)  return;
	var rows=grid.getCheckedRows();
	for(var i=0;i<rows.length;i++)
	{
		if(grid.getCellValueByColumnName(rows[i],"fdStatus")!="草拟")
		{
			EFAlert("只能对草拟的记录生效！"); return;
		}
	}
	EFConfirm('确认要生效吗?', '确认框', function(r) {
		if(r)efgrid.submitForm("ef_grid_result", "ZM", "ZMCG82", "report", true);
	});
}
button_goback_onclick = function (){
	var grid=isSelected("ef_grid_result");
	if (grid == 0)return; 
	var rows=grid.getCheckedRows();
	for(var i=0;i<rows.length;i++)
	{	var sr =grid.getCellValueByColumnName(rows[i],"fdStatus")
		if(grid.getCellValueByColumnName(rows[i],"fdStatus")=="上报")
		{
			EFAlert("只能对草拟的记录进行退回！"); return;
		}
	}
	EFConfirm('确定要退回吗？','确认框',function(r) {
		if(r)efgrid.submitForm( "ef_grid_result", "ZM", "ZMCG82", "goback", true);
	});
}

efgrid_afterAddNewRow = function(grid_id) {
	var grid = efgrid.getGridObject(grid_id);
	var rows = grid.getCheckedRows();
	if (grid_id == "ef_grid_result") {
		for (var i = 0; i < rows.length; i++) {
			grid.getBlockData().setCell(rows[i], "fdStatus", "草拟");
			grid.getBlockData().setCell(rows[i], "fdCurrentDate", getCurrentDate());			
		}
	}
	for (var i = 0; i < rows.length; i++) {
		grid.getBlockData().setCell(rows[i], "fdKeyId", "");
	}
}